<template>
	<!-- 采购录单 -->
	<view class="wrap">
		<u-form :model="userInfoForm" :rules="rules" ref="uForm" :errorType="errorType">

			<!-- <u-form-item :leftIconStyle="{ color: '#888', fontSize: '32rpx' }" left-icon="account" label-width="180"
				:label-position="labelPosition" label="客户名称" prop="customer_name">
				
				<u-input :border="border" v-model="userInfoForm.customer_name" placeholder="请选择客户"></u-input>
				<u-icon slot="right" name="arrow-right" @click="customerSheetShow = true"></u-icon>
			</u-form-item>

			<u-form-item :leftIconStyle="{ color: '#888', fontSize: '32rpx' }" left-icon="edit-pen" label-width="180"
				:label-position="labelPosition" label="联系人" prop="linkman">
				<u-input :border="border" placeholder="请输入联系人" v-model="userInfoForm.linkman" type="text"></u-input>
			</u-form-item>

			<u-form-item :rightIconStyle="{ color: '#888', fontSize: '32rpx' }" right-icon="phone"
				:label-position="labelPosition" label="手机号码" prop="phone" label-width="150">
				<u-input :border="border" placeholder="请输入手机号" v-model="userInfoForm.phone" type="number"></u-input>
			</u-form-item>
			

			<u-form-item label-width="180" :label-position="labelPosition" label="交货类型">
				<u-input :border="border" type="select" :select-open="typelistShow"
					v-model="typelist[Number(userInfoForm.type) - 1].label" placeholder="交货类型"
					@click="typelistShow = true"></u-input>
			</u-form-item>

			<u-picker mode="region" v-model="showRegion" :params="params" :area-code='["45", "4501", "450102"]'
				@confirm="selectRegion"></u-picker>
			<u-form-item label-width=" 100px" label="地址" prop="city" borderBottom ref="item1" @tap="showRegions">
				
				<u-input style="text-align: right;" v-model="userInfoForm.city" disabled disabledColor="#ffffff"
					placeholder="请输入地址"></u-input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>


			<u-form-item label-position="top" label="详细地址" prop="address">
				<u-input type="textarea" :border="border" placeholder="详细地址" v-model="userInfoForm.address" />
			</u-form-item>

			<u-form-item label-width=" 100px" label="类型" prop="form.sex" borderBottom>
				<u-radio-group v-model="userInfoForm.sell_type_str">
					<u-radio v-for="( item, index ) in  radiolist1 " :key="index" :name="item.name"
						@change="radioChange(item.name, index)">
						{{ item.name }}
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<template v-if="radiovalue1 == '锂电池'">
				<u-form-item label-width=" 100px" label="容量" prop="form.load" borderBottom ref="item1">
					<u-input v-model="userInfoForm.capacity" placeholder="请输入容量"></u-input>
				</u-form-item>
				<u-form-item label-width=" 100px" label="车型" prop="form.model" borderBottom ref="item1">
					<u-input v-model="userInfoForm.car_model" placeholder="请输入车型"></u-input>
				</u-form-item>
				<u-form-item label-width=" 100px" label="保护板" prop="form.proboard" borderBottom ref="item1">
					<u-input v-model="userInfoForm.protective_plate" placeholder="请输入保护板"></u-input>
				</u-form-item>
			</template>

			<template v-if="radiovalue1 == '无三大件定制'">
				<u-form-item label-width=" 100px" label="减震颜色" prop="form.jzcolor" borderBottom ref="item1">
					<u-input v-model="userInfoForm.shock_absorber_color" placeholder="请输入减震颜色"></u-input>
				</u-form-item>
				<u-form-item label-width=" 100px" label="卡钳颜色" prop="form.kqcolor" borderBottom ref="item1">
					<u-input v-model="userInfoForm.caliper_color" placeholder="请输入卡钳颜色"></u-input>
				</u-form-item>
				<u-form-item label-width=" 100px" label="轮毂颜色" prop="form.lgcolor" borderBottom ref="item1">
					<u-input v-model="userInfoForm.wheel_hub_color" placeholder="请输入轮毂颜色"></u-input>
				</u-form-item>
				<u-form-item label-width=" 100px" label="车壳颜色" prop="form.ckcolor" borderBottom ref="item1">
					<u-input v-model="userInfoForm.car_body_color" placeholder="请输入车壳颜色"></u-input>
				</u-form-item>
			</template>

			<template v-if="radiovalue1 == '其他'">
				
				<u-form-item borderBottom v-for="( item, index ) in  model1.form.goods " :key="index">
					<view class="flex justify-between">
						<view class="goodsImg">
							<img src="/static/logo.png" alt="">
						</view>
						<view class="flex flex-direction">
							<view style="width: 180px;" class="text-lg text-bold text-cut">{{ item.name }}</view>
							<view class="text-gray">{{ item.hh }}</view>
							<view class="text-gray">{{ item.gg }}</view>
						</view>
						<view class="flex flex-direction">
							<view class="text-lg text-bold">{{ item.prize }}</view>
							<view class="text-gray">{{ item.danwei }}</view>
							<view class="text-gray">{{ item.num }}</view>
						</view>
						<view>
							<u-icon @click="openDeleteGoods(index)" color="red" size="20px"
								name="close-circle-fill"></u-icon>
						</view>
					</view>
				</u-form-item>
			</template> -->
			<view class="orderinfo-contaienr">
				<view class="title  add">
					<view class="font-weight-bold">订单信息：</view>
					<view class="texta">
						<u-input type="textarea" :border="border" placeholder="请填写说明" v-model="userInfoForm.remark" />
					</view>
				</view>
			</view>
			<!-- <u-form-item :label-position="labelPosition" label="说明" prop="remark">
				<u-input type="textarea" :border="border" placeholder="请填写说明" v-model="userInfoForm.remark" />
			</u-form-item> -->
			<u-form-item v-if="userInfoForm.payment_status == 0" label-width=" 100px" label="定金" prop="earnest_money"
				borderBottom ref="item1">
				<u-input v-model="userInfoForm.earnest_money" placeholder="请输入定金"></u-input>
			</u-form-item>
			<!-- 金额 -->
			<u-form-item label-position="top" borderBottom label-width="90px" label="应付金额" prop="real_money">
				<u-input v-model="userInfoForm.real_money" placeholder="请输入应付金额"></u-input>
			</u-form-item>


			<u-form-item label-width="240px" label="生产人员" borderBottom ref="item1">
				<u-input placeholder="请选择生产人员" v-model="userInfoForm.productionpersonobj.nickname"
					disabledColor="#ffffff"></u-input>
				<u-icon slot="right" name="arrow-right" @click="showProducer = true"></u-icon>
			</u-form-item>
			<u-picker @confirm="selectProducer()" @cancel="showProducer = false" mode="selector" v-model="showProducer"
				:range="scmancolumns" range-key="nickname"></u-picker>
			<u-form-item>
				<view class="producePerson">
					<view>
						<u-avatar :src="userInfoForm.productionpersonobj.avatar"></u-avatar>
					</view>
					<view>
						{{ userInfoForm.productionpersonobj.nickname }}
					</view>
					<view>
						电话：{{ userInfoForm.productionpersonobj.mobile }}
					</view>
				</view>
			</u-form-item>

			<!-- 是否组装 true组装 false不组装 -->
			<!-- <u-form-item borderBottom label-width="90px" label="组装">
				<view class="flex flex-direction text-align-right">
					<view class="flex" style="gap: 20px;">
						
						<u-radio-group v-model="userInfoForm.is_assemble_str">
							<u-radio @change="radiozuzhuang(item.name, index)" v-for="(item, index) in zuzhuang"
								:key="index" :name="item.name" :disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
					</view>
					<view class="text-xs text-gray">是否组装发货<text class="text-red">*</text> </view>
				</view>
			</u-form-item> -->
			<!-- 定金或全款 true全款 false定金-->
			<u-form-item borderBottom label-width="90px" label="付款方式">
				<view class="flex flex-direction text-align-right">
					<view class="flex" style="gap: 20px;">
						<!-- <view class="switchtext">定金+尾款</view> -->
						<!-- <u-switch v-model="model1.form.ismoney" @change="changeMoney"></u-switch> -->
						<u-radio-group v-model="userInfoForm.payment_status_str">
							<u-radio @change="radiodinjing(item.name, index)" v-for="(item, index) in dinjing" :key="index"
								:name="item.name" :disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
						<!-- <view class="switchtext">全款</view> -->
					</view>
					<view class="text-xs text-gray">定金请注意收款金额<text class="text-red">*</text> </view>
				</view>
			</u-form-item>
			<!-- 邮寄方式 true包邮 false到付-->
			<u-form-item borderBottom label-width="90px" label="邮寄方式">
				<view class="flex flex-direction text-align-right">
					<view class="flex" style="gap: 20px;">
						<!-- <view class="switchtext">到付</view> -->
						<!-- <u-switch v-model="model1.form.post" @change="changePost"></u-switch> -->

						<u-radio-group v-model="userInfoForm.mailing_type_str">
							<u-radio @change="radioyouji(item.name, index)" v-for="(item, index) in youji" :key="index"
								:name="item.name" :disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
						<!-- <view class="switchtext">包邮</view> -->
					</view>
					<view class="text-xs text-gray">请注意是否包邮<text class="text-red">*</text> </view>
				</view>
			</u-form-item>





			<u-form-item label-position="top" label="上传定金图片" label-width="150" v-if="userInfoForm.payment_status == 0">
				<cl-upload v-model="djimagelist" :action="uploadUrl" @onSuccess="onSuccess"></cl-upload>
			</u-form-item>
			<u-form-item label-position="top" label="上传全款图片" label-width="150" v-else>
				<cl-upload v-model="qkimagelist" :action="uploadUrl" @onSuccess="qkonSuccess"></cl-upload>
			</u-form-item>
			<u-form-item label-position="top" label="上传尾款图片" label-width="150" v-if="wkimagelist.length > 0">
				<cl-upload v-model="wkimagelist" :action="uploadUrl" @onSuccess="wkonSuccess"></cl-upload>
			</u-form-item>









			<view class="mt20">
				<u-section class="mb12" :title="'应付金额(价税合计)￥ ' + totalMoney" :right="false" :show-line="false"></u-section>
			</view>

			<view class="mt20">
				<u-button type="success" :ripple="true" :plain="true" shape="circle" @click="editOrder">立即修改</u-button>
			</view>
		</u-form>

		<u-calendar max-date="2050-01-01" v-model="delivery_timeSheetShow" mode="date" @change="delivery_timeChange"
			toolTip='交货时间'></u-calendar>
		<u-select mode="single-column" :list="customerSelectList" v-model="customerSheetShow"
			@confirm="selectConfirm"></u-select>


		<u-select mode="single-column" :list="typelist" v-model="typelistShow" @confirm="selecttypelistConfirm"></u-select>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
var _this;
import AddressParse from '@/components/xghc-addrress/zh-address-parse.min.js';
export default {
	data() {
		return {
			id: '',
			wkresult: null,
			djresult: null,
			qkresult: null,
			api_root2: '',
			imagelist_str: [],
			uploadUrl: '',
			jiaohuotype: 0,
			producePerson: '',
			dinjing2: 0,
			zuzhuang2: 0,
			youji2: 0,
			radiovalue2: 0,
			zuzhuang: [{
				name: '不组装',
				disabled: false
			},
			{
				name: '组装',
				disabled: false
			}
			],
			dinjing: [{
				name: '定金+尾款',
				disabled: false
			},
			{
				name: '全款',
				disabled: false
			}
			],
			youji: [{
				name: '到付',
				disabled: false
			},
			{
				name: '包邮',
				disabled: false
			}
			],
			showscmancolumns: false,
			scmancolumns: [],
			djimagelist: [],
			wkimagelist: [],
			qkimagelist: [],
			uploadimagelist: [],
			openOrderForm: {
				earnest_money: '',
				customer_name: '',
				linkman: '',
				phone: '',
				delivery_time: '',
				type: '',
				product_id: '',
				product_price: '',
				product_nums: '',
				product_remarks: '',
				product_unit: '',
				product_wait_nums: '',
				product_length: '',
				wait_nums: '',
				total_nums: '',
				city: '',
				address: '',
				rate: '',
				real_money: '',
				theory_money: '',
				remark: '',
				is_assemble: '',
				earnest_money_imgs: '',
				full_payment: '',
				full_payment_imgs: '',
				payment_status: '',
				balance_payment: '',
				balance_payment_imgs: '',
				mailing_type: '',
				sell_type: '',
			},
			model1: {
				customer: '',
				linkman: '',
				form: {
					remark: '',
					city: '',


					address: '',
					sex: '',
					data: '2024-01-24',
					name: '', //客户名称
					phone: '', //电话
					remark: '',
					address: '', //地址
					describe: '', //描述
					producer: '', //生产人

					isAssemble: false, //true组装 false不组装
					ismoney: false, //true全款 false定金
					post: false, //true包邮 false到付
					money: '', //金额
					imgurl: '', //转款截图
					notes: '', //备注


					// 锂电的情况
					load: '', //容量
					model: '', //车型
					proboard: '', //保护板
					deposit: '', //定金

					//无三大定制化的情况
					jzcolor: '', //减震颜色
					kqcolor: '', //卡钳颜色
					lgcolor: '', //轮毂颜色
					ckcolor: '', //车壳颜色
				},
			},
			params: {
				year: true,
				month: true,
				day: true,
				hour: true,
				minute: true,
				second: true,
				province: true,
				city: true,
				area: true,
				timestamp: true
			},
			dateparams: {
				year: true,
				month: true,
				day: true,
				hour: false,
				minute: false,
				second: false
			},
			pasteText: '',
			showRegion: false,
			showSex: false, //是否显示性别选择器
			showData: false, //是否显示日期选择器
			showProducer: false, //是否显示生产人员选择器
			extractedInfo: {
				'名字': '',
				'号码': '',
				'地址': '',
				'容量': '',
				'车型': '',
				'保护板': '',
				'定金': '',
				'减震颜色': '',
				'卡钳颜色': '',
				'轮毂颜色': '',
				'车壳颜色': ''
			},
			//当前的类型
			type: '无三大件定制',


			columns: ['王师傅18878787878', '刘师傅18878787878', '吴师傅18878787878'],


			radiolist1: [{
				name: '无三大件定制',
				disabled: false
			},
			{
				name: '锂电池',
				disabled: false
			},
			{
				name: '其他',
				disabled: false
			},
			],
			// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
			radiovalue1: '无三大件定制',
			zuzhuangValue1: '组装',
			dinjingValue1: '定金+尾款',
			youjiValue1: '到付',
			model: {
				customer: '',
				name: '',
				linkman: '',
				address: '',
				city: '',
				remark: '',
				phone: '',
				telephone: '',
				type: '',
				delivery_time: '', //交货日期
				rate: '16',

			},
			radio: '',
			switchVal: false,
			rules: {
				customer_name: [{
					required: true,
					message: '请选择客户',
					trigger: 'blur',
				}],

				earnest_money: [{
					required: true,
					message: '请输入定金',
					trigger: 'blur',
				}],
				producer: [{
					required: true,
					message: '请选择生产人员',
					trigger: ['blur', 'change'],
				}],
				real_money: [{
					required: true,
					message: '请输入应付金额',
					trigger: 'blur',
				}],
				photo: [{
					required: true,
					message: '请上传截图',
					trigger: 'blur',
				}],
				supplier: [{
					required: true,
					message: '请输入交货方式',
					trigger: 'blur',
				}],
				rate: [{
					required: true,
					message: '请输入税率',
					trigger: 'blur',
				}],
				name: [{
					required: true,
					message: '请输入名称',
					trigger: 'blur',
				}],
				linkman: [{
					required: true,
					message: '请输入联系人111',
					trigger: 'blur',
				}],
				city: [{
					required: true,
					message: '请选择地区',
					trigger: 'change',
				}],
				address: [{
					required: true,
					message: '请选择地区',
					trigger: 'change',
				}],
				type: [{
					required: true,
					message: '请选择仓库类型',
					trigger: 'change',
				}],
				phone: [{
					required: true,
					message: '请输入手机号',
					trigger: ['change', 'blur'],
				},
				{
					validator: (rule, value, callback) => {
						// 调用uView自带的js验证规则，详见：https://www.uviewui.com/js/test.html
						return this.$u.test.mobile(value);
					},
					message: '手机号码不正确',
					// 触发器可以同时用blur和change，二者之间用英文逗号隔开
					trigger: ['change', 'blur'],
				}
				],
				telephone: [{
					required: true,
					message: '请输入座机号码',
					trigger: ['change', 'blur'],
				},
				{
					validator: (rule, value, callback) => {
						// 调用uView自带的js验证规则，详见：https://www.uviewui.com/js/test.html
						return this.$u.test.mobile(value);
					},
					message: '座机号码不正确',
					// 触发器可以同时用blur和change，二者之间用英文逗号隔开
					trigger: ['change', 'blur'],
				}
				],
			},
			pickerShow: false,
			border: false,
			errorType: ['message'],
			labelPosition: 'left',
			unitList: [],
			unitListShow: false,
			chooseScman: '',
			customerSheetShow: false,
			customerList: {}, //供应商列表
			customerSelectList: [], //待选供应商列表
			customerSelectindex: 0, //选择的供应商索引
			userAddress: {
				real_name: "",
				phone: "",
				region: "",
				detail: "",
			}, //地址详情
			delivery_timeSheetShow: false,
			delivery_timetime: null,

			/* 卡片 订单列表 */
			commodityList: [],

			userInfoForm: {
				shock_absorber_color: '',
				productionperson: '',
				earnest_money: '',
				customer_name: '',
				linkman: '',
				phone: '',
				delivery_time: '',
				type: 1,
				product_id: '',
				product_price: '',
				product_nums: '',
				product_remarks: '',
				product_unit: '',
				product_wait_nums: '',
				product_length: '',
				wait_nums: '',
				total_nums: '',
				city: '',
				address: '',
				rate: '',
				real_money: '',
				theory_money: '',
				remark: '',
				is_assemble: '',
				earnest_money_imgs: '',
				full_payment: '',
				full_payment_imgs: '',
				payment_status: '',
				balance_payment: '',
				balance_payment_imgs: '',
				mailing_type: '',
				sell_type: '',
			},
			imageUrl: '',

			/* 类型 交货方式:1=买家自提,2=卖方发货,3=代发*/
			typelistShow: false,
			typelist: [{
				label: '买家自提',
				value: 0,
			}, {
				label: '卖家发货',
				value: 1,
			}, {
				label: '代发',
				value: 2,
			}],
			typelistIndex: 0,
		}

	},
	computed: {
		totalMoney() {

			if (this.userInfoForm.payment_status == 0) {
				return Number(this.userInfoForm.real_money) + Number(this.userInfoForm.earnest_money)
			} else {
				return this.userInfoForm.real_money
			}
			// var totalMoney = 0
			// for (let i = 0; i < this.commodityList.length; i++) {
			// 	totalMoney += this.commodityList[i].num * this.commodityList[i].money
			// }
			// totalMoney = totalMoney + totalMoney * _this.model.rate / 100
			// return totalMoney.toFixed(2);
		}
	},
	onShow() {
		var list = uni.getStorageSync('commodityList');
		if (list) {
			for (let i = 0; i < list.length; i++) {
				let t = true;
				for (let j = 0; j < _this.commodityList.length; j++) {
					if (_this.commodityList[j].id == list[i].id) {
						t = false;
						continue;
					}
				}
				if (t) {
					t = true;
					_this.commodityList.push(list[i])
				}
			}
		}

		uni.removeStorageSync('commodityList')

	},
	onLoad(option) {
		_this = this;
		_this.id = option.id
		_this.getcustomerList();
		_this.getscman();
		_this.getOrderInfo();
		_this.api_root2 = _this.api_root.replace(/\/$/, '');
		_this.uploadUrl = _this.api_root + 'api/common/upload'


	},
	onReady() {
		this.$refs.uForm.setRules(this.rules);
	},
	methods: {
		submitForm() {
			_this.$refs.uForm.validate(valid => {
				if (valid) {

					_this.editOrder()
				} else {

					_this.$refs.uToast.show({
						title: '验证失败',
						type: 'error',
						back: false
					})
				}
			});
		},
		getUsername(event) {

			// const clipboardData = event.clipboardData || window.clipboardData;

			// const pastedText = clipboardData.getData('text');
			const pastedText = this.userInfoForm.remark;
			const fields = ['名字'];

			// 按照换行符分割粘贴的文本
			const lines = pastedText.split('\n');
			console.log('lines: ', lines)

			// 对每一行进行处理
			lines.forEach(line => {
				// 对每个字段进行匹配
				fields.forEach(field => {
					const regExp = new RegExp(`${field}：(.*?)$`);
					const match = line.match(regExp);
					if (match && match[1]) {
						this.extractedInfo[field] = match[1].trim();
					}
				});
			});
			console.log('321', this.extractedInfo)

			this.userInfoForm.customer_name = this.extractedInfo['名字']
			console.log('%c [ this.userInfoForm.customer_name ]-701', 'font-size:13px; background:pink; color:#bf2c9f;', this.userInfoForm.customer_name)

		},
		editOrder() {
			_this.getUsername()
			if (_this.djimagelist.length > 0) {
				_this.djresult = _this.djimagelist.map(function (url) {
					// 检查url是否以_this.api_root开头
					if (url.startsWith(_this.api_root2)) {
						// 如果是，则截取_this.api_root之后的部分并返回
						return url.slice(_this.api_root2.length);
					} else {
						// 如果不是，则添加_this.api_root前缀并返回
						return url;
					}
				});
			}

			if (_this.qkimagelist.length > 0) {
				_this.qkresult = _this.qkimagelist.map(function (url) {
					// 检查url是否以_this.api_root开头
					if (url.startsWith(_this.api_root2)) {
						// 如果是，则截取_this.api_root之后的部分并返回
						return url.slice(_this.api_root2.length);
					} else {
						// 如果不是，则添加_this.api_root前缀并返回
						return url;
					}
				});
			}

			if (_this.djresult == null || _this.djresult == '') {
				_this.userInfoForm.earnest_money_imgs = ''
			} else {
				_this.userInfoForm.earnest_money_imgs = _this.djresult
			}
			if (_this.wkresult == null || _this.wkresult == '') {
				_this.userInfoForm.balance_payment_imgs = ''
			} else {
				_this.userInfoForm.balance_payment_imgs = _this.wkresult
			}
			if (_this.qkresult == null || _this.qkresult == '') {
				_this.userInfoForm.full_payment_imgs = ''
			} else {
				_this.userInfoForm.full_payment_imgs = _this.qkresult
			}
			// _this.userInfoForm.full_payment_imgs = _this.qkresult
			// _this.userInfoForm.balance_payment_imgs = _this.wkresult
			// _this.userInfoForm.sell_type = _this.radiovalue2

			// _this.userInfoForm.earnest_money_imgs =  result


			_this._post_form('api/ykjp/sell/Sell/editSell', _this.userInfoForm, (result) => {
				if (result.code == 1) {
					_this.$refs.uToast.show({
						title: '修改成功',
						type: 'success',
						back: true
					})
					_this.getOrderInfo();
				}

			});
		},
		getOrderInfo() {

			_this._post_form('/api/ykjp/sell/Sell/orderDetail', {
				id: _this.id
			}, (result) => {
				result.data.data.createtime = _this.transformTime(result.data.data.createtime);

				_this.userInfoForm = result.data.data
				let parts = _this.userInfoForm.delivery_time_text.split(' ');
				// 获取年月日部分
				_this.userInfoForm.delivery_time_text = parts[0];


				_this.wkimagelist = _this.userInfoForm.balance_payment_imgs
				_this.qkimagelist = _this.userInfoForm.full_payment_imgs
				_this.djimagelist = _this.userInfoForm.earnest_money_imgs
			});

		},
		getscman() {
			_this._post_form('/api/ykjp/sell/Sell/getscman', {}, (result) => {
				_this.scmancolumns = result.data.data
				console.log('_this.scmancolumns: ', _this.scmancolumns)
				_this.columns = result.data.data.nickname
				console.log('_this.columns: ', _this.columns)
			});
		},
		onremovechoose(index, list) {
			this.imageUrl = null;
		},
		onchoosecomplete(list) {
			this.imageUrl = list[0].url;
		},
		qkonSuccess(reslut) {
			console.log('%c [ reslut ]-815', 'font-size:13px; background:pink; color:#bf2c9f;', reslut)





			_this.qkimagelist = Array.prototype.slice.call(_this.qkimagelist);

			// 把服务端返回的图片地址添加到list中与组件数据同步
			_this.qkimagelist.push(_this.api_root2 + reslut.data.url)

		},
		wkonSuccess(reslut) {
			console.log('%c [ reslut ]-815', 'font-size:13px; background:pink; color:#bf2c9f;', reslut)





			_this.wkimagelist = Array.prototype.slice.call(_this.wkimagelist);

			// 把服务端返回的图片地址添加到list中与组件数据同步
			_this.wkimagelist.push(_this.api_root2 + reslut.data.url)




		},
		onSuccess(reslut) {

			_this.djimagelist = Array.prototype.slice.call(_this.djimagelist);

			// 把服务端返回的图片地址添加到list中与组件数据同步
			_this.djimagelist.push(_this.api_root2 + reslut.data.url)
		},
		sendImage() {
			uni.uploadFile({
				url: _this.api_root + 'api/common/upload',
				filePath: _this.imageUrl,
				name: 'file',
				success: function (res) {
					var e = JSON.parse(res.data)

				},
				complete: function (res) { }
			});
		},
		showRegions() {
			this.showRegion = true
			console.log('this.showRegion: ', this.showRegion)
		},


		addressConfirm(data) {
			console.log(data);
		},
		showRegions() {
			this.showRegion = true
			console.log('this.showRegion: ', this.showRegion)
		},
		getNowFormatDate() {
			let date = new Date(),
				year = date.getFullYear(), //获取完整的年份(4位)
				month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
				strDate = date.getDate() // 获取当前日(1-31)
			if (month < 10) month = `0${month}` // 如果月份是个位数，在前面补0
			if (strDate < 10) strDate = `0${strDate}` // 如果日是个位数，在前面补0

			return `${year}-${month}-${strDate}`
		},
		openDeleteGoods(i) {
			const _this = this
			//删除商品弹窗
			uni.showModal({
				title: '提示',
				content: '是否删除商品',
				// #ifdef APP-PLUS
				showCancel: false,
				// #endif
				success: (res) => {
					if (res.confirm) {
						console.log('客户点击确定');
						_this.deleteGoods(i)
					}
				}
			})
		},
		deleteGoods(i) {
			console.log('%c [ i ]-370', 'font-size:13px; background:pink; color:#bf2c9f;', i)
			//删除商品
			this.model1.form.goods.splice(i, 1)
		},
		//预览图片
		openImg() {
			let imgsArray = this.model1.form.imgurl.split(',');
			uni.previewImage({
				current: 0,
				urls: imgsArray,
			});
		},
		//删除图片弹窗
		openDeleteImg() {
			const _this = this
			//弹框确认是否删除图片
			uni.showModal({
				title: '提示',
				content: '是否删除转款截图',
				// #ifdef APP-PLUS
				showCancel: false,
				// #endif
				success: (res) => {
					if (res.confirm) {
						console.log('客户点击确定');
						_this.deleteImgUrl()
					}
				}
			})
		},
		//删除图片
		deleteImgUrl() {
			this.model1.form.imgurl = ''
		},
		//选择图片
		choosePhoto() {
			const _this = this;
			uni.chooseImage({
				count: 1, //最多可以选择的图片张数，默认9
				sourceType: ['album'], //album 从相册选图，camera 使客相机，默认二者都有。如需直接开相机或直接选相册，请只使客一个选项
				sizeType: ['original'], //original 原图，compressed 压缩图，默认二者都有
				success(res) {
					console.log('选择图片完成', res)
					// 调客上传图片的接口
					// _this.uploadPhoto(res.tempFilePaths);
					_this.model1.form.imgurl = res.tempFilePaths[0]
					console.log('%c [ res.tempFilePaths[0] ]-261',
						'font-size:13px; background:pink; color:#bf2c9f;', res.tempFilePaths[0])
				},
				fail() {
					console.log('失败', err);
				},
				complete() {
					console.log('结束');
				},
			})
		},

		changeMoney(e) {
			console.log('%c [ e ]-904', 'font-size:13px; background:pink; color:#bf2c9f;', e)
			this.model1.form.ismoney = e
		},
		changePost(e) {
			this.model1.form.post = e
		},
		changeAb(e) {
			this.model1.form.isAssemble = e
		},
		selectProducer(e) {
			this.showscmancolumns = true
			this.showProducer = false
			this.chooseScman = e['0']
			console.log('%c [ this.chooseScman ]-939', 'font-size:13px; background:pink; color:#bf2c9f;', this.chooseScman)
			let a = this.chooseScman
			this.userInfoForm.productionpersonobj.nickname = this.scmancolumns[a].nickname
			console.log('%c [ this.model1.form.producer ]-942', 'font-size:13px; background:pink; color:#bf2c9f;', this.model1.form.producer)
			this.userInfoForm.productionperson = this.scmancolumns[a].id

		},
		selectData(e) {
			this.showData = false;
			this.model1.form.data = e.year + '-' + e.month + '-' + e.day

		},
		selectRegion(e) {
			console.log('e: ', e)
			this.showRegion = false;

			this.userInfoForm.city = e.province.label + '/' + e.city.label + '/' + e.area.label
			// this.timeValue = timeValue;
			// console.log(timeValue);


		},
		sexSelect(e) {
			this.model1.form.sex = e.name
			this.$refs.uForm.validateField('form.sex')
		},
		radiodinjing(n, num) {

			this.dinjingValue1 = n

			this.userInfoForm.payment_status = num
			console.log('%c [ this.userInfoForm. ]-1064', 'font-size:13px; background:pink; color:#bf2c9f;', this.userInfoForm.payment_status)

		},
		radioyouji(n, num) {

			this.youjiValue1 = n

			this.userInfoForm.mailing_type = num


		},
		radiozuzhuang(n, num) {

			this.zuzhuangValue1 = n

			this.userInfoForm.is_assemble = num

			console.log('%c [ this.userInfoForm.is_assemble ]-1080', 'font-size:13px; background:pink; color:#bf2c9f;', this.userInfoForm.is_assemble)
			this.radiovalue1 = n
			this.radiovalue2 = num
			console.log('%c [ this.radiovalue2 ]-1169', 'font-size:13px; background:pink; color:#bf2c9f;', this.radiovalue2)
		},

		getcustomerList() {
			_this._post_form('/api/ykjp/information/basisinfo/customerinfo/index', {}, (result) => {
				_this.customerSelectList = [];
				for (let i = 0; i < result.data.data.length; i++) {
					_this.customerSelectList.push({
						label: result.data.data[i].name,
						value: i,
					})
				}
				_this.setData({
					'customerList': result.data.data
				})
			});
		},

		// 选择地区回调
		regionConfirm(e) {
			this.model.city = e.province.label + '/' + e.city.label + '/' + e.area.label;
		},
		// 供应商回调
		selectConfirm(e) {
			e.map((val, index) => {

				this.userInfoForm.customer_name = val.label;
				this.customerSelectindex = val.value;
				this.userInfoForm.linkman = this.customerList[this.customerSelectindex].contact;
				this.userInfoForm.city = this.customerList[this.customerSelectindex].city;
				this.userInfoForm.phone = this.customerList[this.customerSelectindex].phone;
				this.userInfoForm.address = this.customerList[this.customerSelectindex].address;
			})
		},

		/* 选择类型回调 */
		selecttypelistConfirm(e) {
			e.map((val, index) => {


				_this.userInfoForm.type = val.value + 1
				// console.log('%c [ _this.userInfoForm.type ]-1339', 'font-size:13px; background:pink; color:#bf2c9f;', _this.userInfoForm.type)

				this.jiaohuotype = val.value + 1

				this.typelistIndex = val.value;

			})
		},
		/* 选择日期回调 */
		delivery_timeChange(e) {
			console.log('%c [ e ]-1251', 'font-size:13px; background:pink; color:#bf2c9f;', e)

			_this.userInfoForm.delivery_time = e.year + '-' + e.month + '-' + e.day
			_this.userInfoForm.delivery_time_text = e.year + '-' + e.month + '-' + e.day

			_this.delivery_timetime = _this.toTimeData(e.result) / 1000
		},
		onAddOrder(e) {
			uni.navigateTo({
				url: 'addsell'
			})
		},
		ondelOrder(index) {
			_this.commodityList.splice(index, index + 1)
		}

	}
}
</script>


<style scoped lang="scss">
.producePerson {
	margin-top: 20rpx;
	display: flex;
	align-items: center;
	justify-content: space-around;
}

.text-align-right {
	margin-top: 30rpx;
	width: 100%;
	display: flex;
	align-items: flex-end;
}

.goodsImg {
	width: 50px;
	height: 50px;

	img {
		width: 100%;
		height: 100%;
		background-size: cover;
	}
}

.sumbit {
	width: 100%;
	height: 88px;
	text-align: center;
	color: #fff;
	background: #ffffff;
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;

	.btn {
		width: 250px;
		height: 40px;
		background-color: #3C9CFF;
		color: #ffffff;
		text-align: center;
		line-height: 40px;
	}
}

.bgup {
	width: 174px;
	height: 300px;
	background: whitesmoke;
	position: relative;

	.guan {
		position: absolute;
		top: -20px;
		right: -20px;

	}

	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.bg {
	text-align: center;
	width: 174px;
	height: 138px;
	background-image: url('');
	background-size: cover;


}

.zhuankuan {
	text-align: center;
}

.box {}

.switchtext {
	line-height: 25px;

}

.seebtn {
	width: 100px;
	height: 40px;
	padding: 4px;
	text-align: center;
	background: #3C9CFF;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	margin-top: 10px;
	border-radius: 4px;

}

.texta {
	min-height: 100px;
	width: 100%;
	background: #F9F9FB;
	border-radius: 20rpx;
}

.wrap {
	padding: 30rpx;
	background-color: #fff;
}

.title-wrap {
	display: inline-block;
}

.title {
	text-align: left;
	font-size: 28rpx;
	color: $u-content-color;
	margin-top: 20rpx;
}

.ucard {
	background-color: #eaffe5;
}
</style>